package com.fund.order.controller;

import com.fund.common.pojo.Result;
import com.fund.order.pojo.dto.OrderDTO;
import com.fund.order.pojo.vo.OrderVO;
import com.fund.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    OrderService orderService;

    @PostMapping("/purchase")
    public Result<OrderVO> purchaseFund(@RequestBody OrderDTO orderDTO) {
        return orderService.purchaseFund(orderDTO);
    }

    //TODO 测试
    @PostMapping("/redemption")
    public Result<List<OrderVO>> redemptionFund(@RequestBody OrderDTO orderDTO) {
        return orderService.redemptionFund(orderDTO);
    }

    /**
     * 确认所有订单
     * @return
     */
    @PostMapping("/confirm")
    public Result<Boolean> confirmAllOrders(){
        return orderService.confirmAllOrders();
    }

    /**
     * 处理所有的赎回订单
     * @return
     */
    @PostMapping("/redemption/all")
    public Result<Boolean> dealAllRedemptionOrders(){
        return orderService.dealAllRedemptionOrders();
    }

    /**
     * 处理所有的申购订单
     * @return
     */
    @PostMapping("/perchaseOrder/all")
    public Result<Boolean> dealAllPerchaseOrders(){
        return orderService.dealAllPerchaseOrders();
    }
}
